// ==UserScript== // @name 网页继续教育万能自动播放视频倍数,支持国家开放大学|成人本科|继续教育|教师|会计|医生|华医网|好医生|公需课|专业课|网课等均部分支持需要尝试 // @namespace Jay // @version 1.7 // @license MIT // @description 优化倍速窗口UI,增加确认按钮,按要求调整倍速输入(限制为1到16倍)、强制倍速开关与公告的布局,脚本简单明确话! // @author 各种继续教育学习 // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; let currentRate = 1.0; let isMinimized = false; let isForceRateEnabled = true; let modalInstance = null; function setPlaybackRate(rate) { const videos = document.querySelectorAll('video'); videos.forEach(video => { try { video.playbackRate = rate; video.play().catch(() => {}); } catch (error) { console.warn('倍速设置失败,视频不支持倍速播放'); } }); } function forcePlaybackRate() { const videos = document.querySelectorAll('video'); videos.forEach(video => { if (!video.playbackRate) { video.playbackRate = currentRate; } video.play().catch(() => {}); }); } function toggleForceRate() { isForceRateEnabled =!isForceRateEnabled; const status = isForceRateEnabled? '开启' : '关闭'; console.log(`倍速功能已${status}`); modalInstance.querySelector('#forceRateStatus').innerText = `倍速强制功能: ${status}`; if (isForceRateEnabled) { forcePlaybackRate(); } else { resetPlaybackRate(); } } function resetPlaybackRate() { const videos = document.querySelectorAll('video'); videos.forEach(video => { video.playbackRate = 1.0; }); } function createModal() { if (modalInstance) { modalInstance.style.display = 'block'; return modalInstance; } const modal = document.createElement('div'); modal.style.position = 'fixed'; modal.style.left = '0'; modal.style.top = '50%'; modal.style.transform = 'translateY(-50%)'; modal.style.backgroundColor = 'white'; modal.style.padding = '20px'; modal.style.zIndex = '1000'; modal.style.borderRadius = '5px'; modal.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.1)'; modal.style.width = '300px'; modal.style.height = 'auto'; modal.style.textAlign = 'center'; modal.style.fontFamily = 'Arial, sans-serif'; modalInstance = modal; const closeButton = document.createElement('button'); closeButton.textContent = 'x'; closeButton.style.position = 'absolute'; closeButton.style.top = '5px'; closeButton.style.right = '5px'; closeButton.style.padding = '5px 10px'; closeButton.style.fontSize = '18px'; closeButton.style.cursor = 'pointer'; closeButton.style.backgroundColor = 'transparent'; closeButton.style.border = 'none'; closeButton.style.color = '#d9534f'; closeButton.onclick = function() { modal.style.display = 'none'; }; modal.appendChild(closeButton); const minimizeButton = document.createElement('button'); minimizeButton.textContent = '–'; minimizeButton.style.position = 'absolute'; minimizeButton.style.top = '5px'; minimizeButton.style.right = '40px'; minimizeButton.style.padding = '5px 10px'; minimizeButton.style.fontSize = '18px'; minimizeButton.style.cursor = 'pointer'; minimizeButton.style.backgroundColor = 'transparent'; minimizeButton.style.border = 'none'; minimizeButton.style.color = '#5bc0de'; minimizeButton.onclick = function() { toggleMinimize(modal); }; modal.appendChild(minimizeButton); const rateLabel = document.createElement('label'); rateLabel.innerText = '请输入倍速(1-16):'; modal.appendChild(rateLabel); const rateInput = document.createElement('input'); rateInput.type = 'number'; rateInput.step = '0.1'; rateInput.min = '1'; rateInput.max = '16'; rateInput.value = currentRate; rateInput.style.marginTop = '10px'; rateInput.style.fontSize = '16px'; rateInput.style.padding = '5px'; rateInput.style.width = '100px'; modal.appendChild(rateInput); const confirmButton = document.createElement('button'); confirmButton.innerText = '确认'; confirmButton.style.marginTop = '20px'; confirmButton.style.padding = '5px 10px'; confirmButton.style.fontSize = '14px'; confirmButton.style.cursor = 'pointer'; confirmButton.style.width = '100%'; confirmButton.onclick = function() { let newRate = parseFloat(rateInput.value); if (!isNaN(newRate) && newRate >= 1 && newRate <= 16) { currentRate = newRate; setPlaybackRate(currentRate); } else { alert('请输入有效的倍速值(1到16之间)。'); } }; modal.appendChild(confirmButton); const toggleRateButton = document.createElement('button'); toggleRateButton.innerText = isForceRateEnabled? '关闭倍速强制' : '开启倍速强制'; toggleRateButton.style.marginTop = '20px'; toggleRateButton.style.padding = '5px 10px'; toggleRateButton.style.fontSize = '14px'; toggleRateButton.style.cursor = 'pointer'; toggleRateButton.style.width = '100%'; toggleRateButton.onclick = function() { toggleForceRate(); toggleRateButton.innerText = isForceRateEnabled? '关闭倍速强制' : '开启倍速强制'; }; modal.appendChild(toggleRateButton); const rateStatus = document.createElement('p'); rateStatus.id = 'forceRateStatus'; rateStatus.innerText = `倍速强制功能: ${isForceRateEnabled? '开启' : '关闭'}`; rateStatus.style.marginTop = '20px'; rateStatus.style.fontSize = '14px'; rateStatus.style.color = '#555'; modal.appendChild(rateStatus); const additionalInfo = document.createElement('div'); additionalInfo.innerHTML = ` 倍速需谨慎
不是所有的学习平台都可以进行倍数
该平台是否支持请自行测试
若没记录则表示为不可以
添加仅解决代刷问题非脚本问题
需要帮忙学习联系 v:study-088 流量不够用点击此处可免费申请流量卡 `; additionalInfo.style.fontSize = '16px'; additionalInfo.style.color = '#777'; additionalInfo.style.marginTop = '10px'; modal.appendChild(additionalInfo); document.body.appendChild(modal); return modal; } function toggleMinimize(modal) { if (isMinimized) { modal.style.height = 'auto'; modal.style.padding = '20px'; modal.querySelector('input').style.display = 'block'; modal.querySelector('button').style.display = 'block'; modal.querySelector('p').style.display = 'block'; modal.querySelector('div').style.display = 'block'; isMinimized = false; modal.querySelector('button:nth-child(2)').textContent = '–'; } else { modal.style.height = '40px'; modal.style.padding = '10px'; modal.querySelector('input').style.display = 'none'; modal.querySelector('button').style.display = 'none'; modal.querySelector('p').style.display = 'none'; modal.querySelector('div').style.display = 'none'; isMinimized = true; modal.querySelector('button:nth-child(2)').textContent = '展开'; } } createModal(); setInterval(() => { if (isForceRateEnabled) { forcePlaybackRate(); // 强制倍速 } }, 1000); })();